﻿
@{
    ViewBag.Title = "title";

}

<h2>Demo index</h2>

<div class="row">
    <select id="s1"></select>
    <hr />
    <input type="text" value="" id="t1" />
    <input type="text" value="" id="t2" />
    <button type="button">提交</button>
</div>


@section scripts
{
    <script>
        $(function () {
            $.ajax({
                url: "/demo/productlist",
                data: null,
                type: "GET",
                success: function (res) {
                    var str = "";
                    for (var i = 0; i < res.length; i++) {
                        str += "<option>" + res[i].Title + '</option>';
                    }
                    $("#s1").html(str);
                },
                error: function (r) {
                    console.error("/demo/productlist 出错了");
                }

            });

            $("button").click(function () {
                var t1 = $("#t1").val();
                var t2 = $("#t2").val();
                $.ajax({
                    url: "/demo/submit2",
                    data: {
                        title: t1,
                        value: t2
                    },
                    type:"POST",
                    success: function (res) {
                        alert('success ' + res.ok);
                    },
                    error: function (r) {
                        console.error("/demo/submit 出错了");
                    }
                });
            });

        });
    </script>
}
